﻿using UnityEngine;
using System.Collections;

public class mEndLessEntry : MonoBehaviour
{
    public UIPanel panel;

    public UIWidget widget;

    public Transform mTrans;

    public mAniamtionCurve mAnim;
    
    void OnEnable()
    {
        mTrans = transform;

        panel = NGUITools.FindInParents<UIPanel>(gameObject);

        widget = GetComponent<UIWidget>();

        mAnim = Resources.Load<mAniamtionCurve>("mAnim");
    }

    #region View
    public void UpdateScrollView(float factor)
    {
        if (factor < 0 || factor > 1) Debug.Log("this ?!" + factor);

        Vector3 nowLocalEuler = transform.eulerAngles;
        nowLocalEuler.x = mAnim.localEulerX.Evaluate(factor);
        transform.eulerAngles = nowLocalEuler;

        Vector3 nowLocalPos = transform.localPosition;
        nowLocalPos.z = mAnim.localPosZ.Evaluate(factor);
        transform.localPosition = nowLocalPos;

        widget.width = (int)mAnim.widthCurve.Evaluate(factor);
        widget.height = (int)mAnim.heightCurve.Evaluate(factor);
        
    }
    #endregion
}
